home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / qxembed.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-02-13  |  7.8 KB  |  235 lines

  1. /****************************************************************************
  2.     Definition of QXEmbed class
  3.  
  4.    Copyright (C) 1999-2000 Troll Tech AS
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.  
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.     Boston, MA 02110-1301, USA.
  20. *****************************************************************************/
  21.  
  22. #ifndef QXEMBED_H
  23. #define QXEMBED_H
  24.  
  25. #include <qwidget.h>
  26. #include <kdelibs_export.h>
  27.  
  28. #ifdef Q_WS_X11
  29.  
  30. class QXEmbedData;
  31.  
  32. /**
  33.  * A QXEmbed widget serves as an embedder that can manage one single embedded
  34.  * X-window. These so-called client windows can be arbitrary Qt or non Qt
  35.  * applications.
  36.  *
  37.  * There are two different ways of using QXEmbed,
  38.  * from the client side or from the embedder's side.
  39.  * 
  40.  * Embedding from the client's side requires that the client knows the
  41.  * window identifier of the respective embedder widget. Use either
  42.  * embedClientIntoWindow() or the high-level wrapper processClientCmdline().
  43.  * This is only possible when the client is a Qt application.
  44.  *
  45.  * When using it from the embedder's side, you must know the window 
  46.  * identifier of the window that should be embedded. Simply call embed() 
  47.  * with this identifier as parameter.  If the client is a Qt application,
  48.  * make sure it has called QXEmbed::initialize(). Otherwise you should
  49.  * probably call setProtocol(XPLAIN) before embed().
  50.  * 
  51.  * Reimplement the change handler windowChanged() to catch embedding or
  52.  * the destruction of embedded windows. In the latter case, the
  53.  * embedder also emits a signal embeddedWindowDestroyed() for
  54.  * convenience.
  55.  *
  56.  * @short The QXEmbed widget is a graphical socket that can embed an external X-Window.
  57. */
  58. class KDEUI_EXPORT QXEmbed : public QWidget
  59. {
  60.     Q_OBJECT
  61.  
  62. public:
  63.  
  64.     /**
  65.      *
  66.      * Constructs a xembed widget.
  67.      *
  68.      * The parent, name and f arguments are passed to the QFrame
  69.      * constructor.
  70.      */
  71.     QXEmbed( QWidget *parent=0, const char *name=0, WFlags f = 0 );
  72.  
  73.     /**
  74.      * Destructor. Cleans up the focus if necessary.
  75.      */
  76.     ~QXEmbed();
  77.  
  78.     /**
  79.      * Embedded applications should call this function to make sure
  80.      * they support the XEMBED protocol. It is called automatically
  81.      * when you use embedClientIntoWindow() or
  82.      * processClientCmdline(). Clients might have to call it
  83.      * manually when you use embed().
  84.      */
  85.     static void initialize();
  86.  
  87.     enum Protocol { XEMBED, XPLAIN };
  88.  
  89.     /**
  90.      * Sets the protocol used for embedding windows.
  91.      * This function must be called before embedding a window.
  92.      * Protocol XEMBED provides maximal functionality (focus, tabs, etc)
  93.      * but requires explicit cooperation from the embedded window.
  94.      * Protocol XPLAIN provides maximal compatibility with
  95.      * embedded applications that do not support the XEMBED protocol.
  96.      * The default is XEMBED.
  97.      *
  98.      * Non KDE applications should be embedded with protocol XPLAIN. 
  99.      * This does not happen automatically yet. 
  100.      * You must call setProtocol() explicitly.
  101.      */
  102.  
  103.     void setProtocol( Protocol proto );
  104.  
  105.     /**
  106.      * Returns the protocol used for embedding the current window.
  107.      *
  108.      * @return the protocol used by QXEmbed.
  109.      */
  110.  
  111.     Protocol protocol();
  112.  
  113.     /**
  114.      * Embeds the window with the identifier w into this xembed widget.
  115.      *
  116.      * This function is useful if the embedder knows about the client window
  117.      * that should be embedded.  Often it is vice versa: the client knows
  118.      * about its target embedder. In that case, it is not necessary to call
  119.      * embed(). Instead, the client will call the static function
  120.      * embedClientIntoWindow().
  121.      *
  122.      * @param w the identifier of the window to embed
  123.      * @see embeddedWinId()
  124.      */
  125.     void embed( WId w );
  126.  
  127.     /**
  128.      * Returns the window identifier of the embedded window, or 0 if no
  129.      * window is embedded yet.
  130.      *
  131.      * @return the id of the embedded window (0 if no window is embedded)
  132.      */
  133.     WId embeddedWinId() const;
  134.  
  135.     /**
  136.      * A function for clients that embed themselves. The widget
  137.      * client will be embedded in the window window. The application has
  138.      * to ensure that window is the handle of the window identifier of
  139.      * an QXEmbed widget.
  140.      *
  141.      * @short #processClientCmdline()
  142.      */
  143.     static void embedClientIntoWindow( QWidget* client, WId window );
  144.  
  145.     /**
  146.      * A utility function for clients that embed theirselves. The widget
  147.      * client will be embedded in the window that is passed as
  148.      * -embed command line argument.
  149.      *
  150.      * The function returns true on success or false if no such command line
  151.      * parameter is specified.
  152.      *
  153.      * @see embedClientIntoWindow()
  154.      */
  155.     static bool processClientCmdline( QWidget* client, int& argc, char ** argv );
  156.  
  157.     /** 
  158.      * Sends a WM_DELETE_WINDOW message to the embedded window.  This is what
  159.      * typically happens when you click on the close button of a window
  160.      * manager decoration.  This should cause the embedded application to
  161.      * cleanly close the window.  Signal embeddedWindowDestroyed() can be used
  162.      * to monitor the status of the embedded window.
  163.      */
  164.     void sendDelete( void );
  165.     
  166.     /**
  167.      * Selects what shoud be done with the embedded window when the embedding
  168.      * window is destroyed.  When the argument is true, the embedded window is
  169.      * kept alive, is hidden, and receives a WM_DELETE_WINDOW message using
  170.      * sendDelete().  This is the default.  Otherwise, the destruction of the
  171.      * QXEmbed object simply destroys the embedded window.
  172.      *
  173.      * @see sendDelete()
  174.      */
  175.     void setAutoDelete( bool );
  176.  
  177.     /**
  178.      * Returns the value of flag indicating what shoud be done with the
  179.      * embedded window when the embedding window is destroyed.
  180.      * 
  181.      * @see setAutoDelete()
  182.      */
  183.     bool autoDelete() const;
  184.  
  185.     /* Reimp */
  186.     QSize sizeHint() const;
  187.     QSize minimumSizeHint() const;
  188.     QSizePolicy sizePolicy() const;
  189.     bool eventFilter( QObject *, QEvent * );
  190.     bool customWhatsThis() const;
  191.     void enterWhatsThisMode(); // temporary, fix in Qt (Matthias, Mon Jul 17 15:20:55 CEST 2000  )
  192.     virtual void reparent( QWidget * parent, WFlags f, const QPoint & p, bool showIt = false );
  193.  
  194. signals:
  195.     /**
  196.      * This signal is emitted when the embedded window has been lost (destroyed or reparented away)
  197.      *
  198.      * @see embeddedWinId()
  199.      */
  200.     // KDE4 rename to embeddedWindowLost()
  201.     void embeddedWindowDestroyed();
  202.  
  203. protected:
  204.     bool event( QEvent * );
  205.     void keyPressEvent( QKeyEvent * );
  206.     void keyReleaseEvent( QKeyEvent * );
  207.     void focusInEvent( QFocusEvent * );
  208.     void focusOutEvent( QFocusEvent * );
  209.     void resizeEvent(QResizeEvent *);
  210.     void showEvent( QShowEvent * );
  211.     bool x11Event( XEvent* );
  212.  
  213.     /**
  214.      * A change handler that indicates that the embedded window has been
  215.      * changed.  The window handle can also be retrieved with
  216.      * embeddedWinId().
  217.      *
  218.      * @param w the handle of the window that changed
  219.      */
  220.     virtual void windowChanged( WId w );
  221.  
  222.     bool focusNextPrevChild( bool next );
  223.  
  224. private:
  225.     WId window;
  226.     QXEmbedData* d;
  227.     void checkGrab();
  228.     void sendSyntheticConfigureNotifyEvent();
  229.     void handleEmbed();
  230. };
  231.  
  232.  
  233. #endif
  234. #endif
  235.